package com.tulei.admin.controller;


import com.tulei.common.response.R;
import com.tulei.common.utils.RedisUtils;
import com.tulei.system.Entity.SysRole;
import com.tulei.system.service.CodeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @Author TuLei
 * @Date 2024-06-13 11:29
 **/

@RequiredArgsConstructor
@RestController
@Api(value = "验证码管理", tags = {"验证码管理"})
@RequestMapping(value = "api/code", method = {RequestMethod.POST, RequestMethod.GET})
public class CodeController {


    private final CodeService codeService;


    private final RedisUtils redisUtils;

    @GetMapping
    @ApiOperation("获取验证码")
    public R<Map<String, Object>> getCode() {
        return codeService.getCode();
    }


    @PostMapping("/add")
    public R<Void> add(@RequestBody SysRole role){
        redisUtils.set("test", role);
        return R.ok();
    }
}
